﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using Facade;
using IronOne.SalesOne.BusinessObjects;

namespace IronOne.SalesOne.SalesOneWeb.UserManagement
{
    public partial class CodeType : SOSecurityPage, IDataPage
    
    {
        List<Country> countries;
        List<IDType> idtypes;
        List<InformationType> informationtypes;
        List<MaritalStatus> maritalstatuss;
        List<Measure> measures;
        List<Month> months;
        List<PaymentMode> paymentmodes;
        List<PendingRequirement> pendingrequirements;
        List<PendingStatus> pendingstatuss;
        List<PolicyStatus> policystatuss;
        List<PolicyType> policytypes;
        List<Salutation> salutations;
        List<SOType> sotypes;
        List<ComplaintType> complainttypes;
        List<ComplaintStatus> complaintstatuss;
        List<CompetionType> competiontypes;
        List<CompaintSubType> complaintsubtypes;
        List<ClaimStatus> claimstatuss;

        CodeFacade codeFacede = new CodeFacade();

        int successDel = 0;
        
        protected void Page_Load(object sender, EventArgs e)
        {
                    
            String codeType = string.Empty;
            String codeTypeUp = string.Empty;

         
                //Button btn = (Button)this.UCGridButtons1.FindControl("btnDelete");
                //btn.Attributes.Add("onClick","javascript:myFunction()");

                UCGridButtons1.SetCredentials(ValidateUserCredentials(Request.Url.LocalPath));
                UCGridButtons2.SetCredentials(ValidateUserCredentials(Request.Url.LocalPath));
                
                
                lblUpdateMsg.Text = "";

                if (Session["successCodeUpdate"] != null)
                {
                    lblUpdateMsg.Text = Session["successCodeUpdate"].ToString() + (Request.QueryString["tt"]);
                    lblUpdateMsg.ForeColor = System.Drawing.Color.Green;
                    Session.Remove("successCodeUpdate");
                }

                if (Session["failCodeUpdate"] != null)
                {
                    lblUpdateMsg.Text = Session["failCodeUpdate"].ToString() + (Request.QueryString["tt"]);
                    lblUpdateMsg.ForeColor = System.Drawing.Color.Red;
                    Session.Remove("failCodeUpdate");
                }
                
                if (!Page.IsPostBack)
                {

                    if (Request.QueryString["t"] != null)
                    
                    {
                        codeType = Request.QueryString["t"];
                        SelectCodeTypeTables(codeType);
                        TypeDropDownList.SelectedValue = codeType;
                        
                    }
                    if (Request.QueryString["tt"] != null)
                    {
                        
                        codeTypeUp = Request.QueryString["tt"];
                        SelectCodeTypeTables(codeTypeUp);
                        TypeDropDownList.SelectedValue = codeTypeUp;
                        
                    }
                }
                else
                {
                    
                }

                if (!IsPostBack && (Request.QueryString["tt"] != null))
                {
                    this.UCGridButtons1.Visible = true;
                    this.UCGridButtons2.Visible = true;
                    return;
                    
                }

                if (!IsPostBack && (Request.QueryString["t"] != null))
                {

                    this.UCGridButtons1.Visible = true;
                    this.UCGridButtons2.Visible = true;
                    return;
                    
                }

               else if (!IsPostBack)
                {
                    this.UCGridButtons1.Visible = false;
                    this.UCGridButtons2.Visible = false;
                }
                else
                {
                    this.UCGridButtons1.Visible = true;
                    this.UCGridButtons2.Visible = true;
                    
                }

        }

        #region IDataPage Members

        public void Create()
        {
            
            Response.Redirect("~/UserManagement/ManageCodeTypeCreate.aspx?a=c&t="+(TypeDropDownList.Text), false);
            
        }

        public void View()
        {
            
        }

        public void Update()
        {
            if (Session["codeId"] != null)
            {
                Response.Redirect("~/UserManagement/ManageCodeTypeCreate.aspx?a=u&tt=" + (TypeDropDownList.Text), false);
                
            }
            else
            {
                lblUpdateMsg.Font.Bold = true;
                lblUpdateMsg.ForeColor = System.Drawing.Color.Red;
                lblUpdateMsg.Text = "Please select a row to update.";
              
            }
        }
        public void Delete()
        {
            if ((Session["codeId"] != null))
            {
                //Response.Write("<script>confirm('Are you sure you want to delete this?');</script>");
                //Response.Write("<script>alert('You have successfully created a ' + '" + selectedTable + "')</script>");
                DeleteCodeTypes();
                SelectCodeTypeTables(TypeDropDownList.Text);
                Session["codeId"] = null;

            }
            else {
                lblUpdateMsg.Font.Bold = true;
                lblUpdateMsg.ForeColor = System.Drawing.Color.Red;
                lblUpdateMsg.Text = "Please select a row to delete.";
                Session["codeId"] = null;
            }
        }

        public void Cancel()
        {

        }

        #endregion

       private void SelectCodeTypeTables(String codeType)
        {
           

            codeFacede = new CodeFacade();
            //int[] hideColumn = { 1 };
            int[] hideColumn = { 1 ,2};



            switch (codeType)
            {
                case "Country":
                    countries = codeFacede.GetCountries("CodeId ASC");
                   
                        UCGrid1.SetDataSource(countries, hideColumn);
                   
                    break;
                case "Month":
                    months = codeFacede.GetMonths("CodeId ASC");
                    
                        UCGrid1.SetDataSource(months, hideColumn);
                    
                    break;

                case "IDType":
                    idtypes = codeFacede.GetIDTypes("CodeId ASC");
                       UCGrid1.SetDataSource(idtypes, hideColumn);
                   
                    break;
                case "ClaimStatus":
                    claimstatuss = codeFacede.GetClaimStatuss("CodeId ASC");
                    
                        UCGrid1.SetDataSource(claimstatuss, hideColumn);
                  

                    break;
                case "CompaintSubType":
                    complaintsubtypes = codeFacede.GetCompaintSubTypes("CodeId ASC");
                    
                        UCGrid1.SetDataSource(complaintsubtypes, hideColumn);
                    
                    break;

                case "CompetionType":
                    competiontypes = codeFacede.GetCompetionTypes("CodeId ASC");
                    
                    
                    break;

                case "ComplaintStatus":
                    complaintstatuss = codeFacede.GetComplaintStatuss("CodeId ASC");
                    
                        UCGrid1.SetDataSource(complaintstatuss, hideColumn);
                   
                    break;
                case "ComplaintType":
                    complainttypes = codeFacede.GetComplaintTypes("CodeId ASC");
                    
                        UCGrid1.SetDataSource(complainttypes, hideColumn);
                   
                    break;
                case "InformationType":
                    informationtypes = codeFacede.GetInformationTypes("CodeId ASC");
                    
                        UCGrid1.SetDataSource(informationtypes, hideColumn);
                   
                    break;
                case "MaritalStatus":
                    maritalstatuss = codeFacede.GetMaritalStatuss("CodeId ASC");
                    
                        UCGrid1.SetDataSource(maritalstatuss, hideColumn);
                    
                    break;
                case "PolicyType":
                    policytypes = codeFacede.GetPolicyTypes("CodeId ASC");
                    
                        UCGrid1.SetDataSource(policytypes, hideColumn);
                   
                    break;
                case "Salutation":
                    salutations = codeFacede.GetSalutations("CodeId ASC");
                    
                        UCGrid1.SetDataSource(salutations, hideColumn);
                    
                    break;
                case "Measure":
                    measures = codeFacede.GetMeasures("CodeId ASC");
                    
                        UCGrid1.SetDataSource(measures, hideColumn);
                    
                    break;
                case "SOType":
                    sotypes = codeFacede.GetSOTypes("CodeId ASC");
                    
                        UCGrid1.SetDataSource(sotypes, hideColumn);
                    
                    break;
                case "PaymentMode":
                    paymentmodes = codeFacede.GetPaymentModes("CodeId ASC");
                    
                        UCGrid1.SetDataSource(paymentmodes, hideColumn);
                    
                    break;
                case "PendingRequirement":
                    pendingrequirements = codeFacede.GetPendingRequirements("CodeId ASC");
                    
                        UCGrid1.SetDataSource(pendingrequirements, hideColumn);
                    
                    break;
                case "PendingStatus":
                    pendingstatuss = codeFacede.GetPendingStatuss("CodeId ASC");
                    
                        UCGrid1.SetDataSource(pendingstatuss, hideColumn);
                    
                    break;
                case "PolicyStatus":
                    policystatuss = codeFacede.GetPolicyStatuss("CodeId ASC");
                    
                        UCGrid1.SetDataSource(policystatuss, hideColumn);
                    
                    break;
                case "Select...":
                    Response.Redirect("~/UserManagement/CodeType.aspx", false);
                    //Server.Transfer("~/UserManagement/CodeType.aspx");
                    break;

                default:
                    break;

            }








            //switch (codeType)
            //{
            //    case "Country":
            //        countries = codeFacede.GetCountries("CodeId ASC");
            //        if (countries.Count >0)
            //        {
            //            UCGrid1.SetDataSource(countries, hideColumn);
            //        }
            //        else {
                        
            //            //Response.Write("<script>alert('The data table is empty.So please enter some data !!!');</script>");
            //            UCGridButtons1.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons1.FindControl("btnDelete").Visible = false;
            //            UCGridButtons1.FindControl("btnCreate").Visible = false;
            //            UCGridButtons2.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons2.FindControl("btnDelete").Visible = false;
            //            lblUpdateMsg.Font.Bold = true;
            //            lblUpdateMsg.ForeColor = System.Drawing.Color.Red;
            //            lblUpdateMsg.Text = ("The data table is empty.So please enter some data !!!");
            //        }
            //        break;
            //    case "Month":
            //        months = codeFacede.GetMonths("CodeId ASC");
            //        if (months.Count > 0)
            //        {
            //            UCGrid1.SetDataSource(months, hideColumn);
            //        }
            //        else
            //        {
            //            //Response.Write("<script>alert('The data table is empty.So please enter some data !!!');</script>");
            //            UCGridButtons1.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons1.FindControl("btnDelete").Visible = false;
            //            UCGridButtons1.FindControl("btnCreate").Visible = false;
            //            UCGridButtons2.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons2.FindControl("btnDelete").Visible = false;
            //        }
            //        break;

            //    case "IDType":
            //        idtypes = codeFacede.GetIDTypes("CodeId ASC");
            //        if (idtypes.Count > 0)
            //        {
            //        UCGrid1.SetDataSource(idtypes, hideColumn);
            //        }
            //        else
            //        {
            //            //Response.Write("<script>alert('The data table is empty.So please enter some data !!!');</script>");
            //            UCGridButtons1.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons1.FindControl("btnDelete").Visible = false;
            //            UCGridButtons1.FindControl("btnCreate").Visible = false;
            //            UCGridButtons2.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons2.FindControl("btnDelete").Visible = false;
            //        }
            //        break;
            //    case "ClaimStatus":
            //        claimstatuss = codeFacede.GetClaimStatuss("CodeId ASC");
            //        if (claimstatuss.Count > 0)
            //        {
            //        UCGrid1.SetDataSource(claimstatuss, hideColumn);
            //        }
            //        else
            //        {
            //            //Response.Write("<script>alert('The data table is empty.So please enter some data !!!');</script>");
            //            UCGridButtons1.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons1.FindControl("btnDelete").Visible = false;
            //            UCGridButtons1.FindControl("btnCreate").Visible = false;
            //            UCGridButtons2.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons2.FindControl("btnDelete").Visible = false;
            //        }

            //        break;
            //    case "CompaintSubType":
            //        complaintsubtypes = codeFacede.GetCompaintSubTypes("CodeId ASC");
            //        if (complaintsubtypes.Count > 0)
            //        {
            //        UCGrid1.SetDataSource(complaintsubtypes, hideColumn);
            //        }
            //        else
            //        {
            //            //Response.Write("<script>alert('The data table is empty.So please enter some data !!!');</script>");
            //            UCGridButtons1.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons1.FindControl("btnDelete").Visible = false;
            //            UCGridButtons1.FindControl("btnCreate").Visible = false;
            //            UCGridButtons2.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons2.FindControl("btnDelete").Visible = false;
            //        }
            //        break;

            //    case "CompetionType":
            //        competiontypes = codeFacede.GetCompetionTypes("CodeId ASC");
            //        if (competiontypes.Count > 0)
            //        {
            //        UCGrid1.SetDataSource(competiontypes,hideColumn);
            //        }
            //        else
            //        {
            //            //Response.Write("<script>alert('The data table is empty.So please enter some data !!!');</script>");
            //            UCGridButtons1.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons1.FindControl("btnDelete").Visible = false;
            //            UCGridButtons1.FindControl("btnCreate").Visible = false;
            //            UCGridButtons2.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons2.FindControl("btnDelete").Visible = false;
            //        }
            //        break;
              
            //    case "ComplaintStatus":
            //        complaintstatuss = codeFacede.GetComplaintStatuss("CodeId ASC");
            //        if (complaintstatuss.Count > 0)
            //        {
            //        UCGrid1.SetDataSource(complaintstatuss, hideColumn);
            //        }
            //        else
            //        {
            //            //Response.Write("<script>alert('The data table is empty.So please enter some data !!!');</script>");
            //            UCGridButtons1.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons1.FindControl("btnDelete").Visible = false;
            //            UCGridButtons1.FindControl("btnCreate").Visible = false;
            //            UCGridButtons2.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons2.FindControl("btnDelete").Visible = false;
            //        }
            //        break;
            //    case "ComplaintType":
            //        complainttypes = codeFacede.GetComplaintTypes("CodeId ASC");
            //        if (complainttypes.Count > 0)
            //        {
            //        UCGrid1.SetDataSource(complainttypes, hideColumn);
            //        }
            //        else
            //        {
            //            //Response.Write("<script>alert('The data table is empty.So please enter some data !!!');</script>");
            //            UCGridButtons1.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons1.FindControl("btnDelete").Visible = false;
            //            UCGridButtons1.FindControl("btnCreate").Visible = false;
            //            UCGridButtons2.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons2.FindControl("btnDelete").Visible = false;
            //        }
            //        break;
            //    case "InformationType":
            //        informationtypes = codeFacede.GetInformationTypes("CodeId ASC");
            //        if (informationtypes.Count > 0)
            //        {
            //        UCGrid1.SetDataSource(informationtypes, hideColumn);
            //        }
            //        else
            //        {
            //            //Response.Write("<script>alert('The data table is empty.So please enter some data !!!');</script>");
            //            UCGridButtons1.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons1.FindControl("btnDelete").Visible = false;
            //            UCGridButtons1.FindControl("btnCreate").Visible = false;
            //            UCGridButtons2.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons2.FindControl("btnDelete").Visible = false;
            //        }
            //        break;
            //    case "MaritalStatus":
            //        maritalstatuss = codeFacede.GetMaritalStatuss("CodeId ASC");
            //        if (maritalstatuss.Count > 0)
            //        {
            //        UCGrid1.SetDataSource(maritalstatuss, hideColumn);
            //        }
            //        else
            //        {
            //            //Response.Write("<script>alert('The data table is empty.So please enter some data !!!');</script>");
            //            UCGridButtons1.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons1.FindControl("btnDelete").Visible = false;
            //            UCGridButtons1.FindControl("btnCreate").Visible = false;
            //            UCGridButtons2.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons2.FindControl("btnDelete").Visible = false;
            //        }
            //        break;
            //    case "PolicyType":
            //        policytypes = codeFacede.GetPolicyTypes("CodeId ASC");
            //        if (policytypes.Count > 0)
            //        {
            //        UCGrid1.SetDataSource(policytypes, hideColumn);
            //        }
            //        else
            //        {
            //            //Response.Write("<script>alert('The data table is empty.So please enter some data !!!');</script>");
            //            UCGridButtons1.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons1.FindControl("btnDelete").Visible = false;
            //            UCGridButtons1.FindControl("btnCreate").Visible = false;
            //            UCGridButtons2.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons2.FindControl("btnDelete").Visible = false;
            //        }
            //        break;
            //    case "Salutation":
            //        salutations = codeFacede.GetSalutations("CodeId ASC");
            //        if (salutations.Count > 0)
            //        {
            //        UCGrid1.SetDataSource(salutations, hideColumn);
            //        }
            //        else
            //        {
            //            //Response.Write("<script>alert('The data table is empty.So please enter some data !!!');</script>");
            //            UCGridButtons1.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons1.FindControl("btnDelete").Visible = false;
            //            UCGridButtons1.FindControl("btnCreate").Visible = false;
            //            UCGridButtons2.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons2.FindControl("btnDelete").Visible = false;
            //        }
            //        break;
            //    case "Measure":
            //        measures = codeFacede.GetMeasures("CodeId ASC");
            //        if (measures.Count > 0)
            //        {
            //        UCGrid1.SetDataSource(measures, hideColumn);
            //        }
            //        else
            //        {
            //            //Response.Write("<script>alert('The data table is empty.So please enter some data !!!');</script>");
            //            UCGridButtons1.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons1.FindControl("btnDelete").Visible = false;
            //            UCGridButtons1.FindControl("btnCreate").Visible = false;
            //            UCGridButtons2.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons2.FindControl("btnDelete").Visible = false;
            //        }
            //        break;
            //    case "SOType":
            //        sotypes = codeFacede.GetSOTypes("CodeId ASC");
            //        if (sotypes.Count > 0)
            //        {
            //        UCGrid1.SetDataSource(sotypes, hideColumn);
            //        }
            //        else
            //        {
            //            //Response.Write("<script>alert('The data table is empty.So please enter some data !!!');</script>");
            //            UCGridButtons1.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons1.FindControl("btnDelete").Visible = false;
            //            UCGridButtons1.FindControl("btnCreate").Visible = false;
            //            UCGridButtons2.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons2.FindControl("btnDelete").Visible = false;
            //        }
            //        break;
            //    case "PaymentMode":
            //        paymentmodes = codeFacede.GetPaymentModes("CodeId ASC");
            //        if (paymentmodes.Count > 0)
            //        {
            //        UCGrid1.SetDataSource(paymentmodes, hideColumn);
            //        }
            //        else
            //        {
            //            //Response.Write("<script>alert('The data table is empty.So please enter some data !!!');</script>");
            //            UCGridButtons1.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons1.FindControl("btnDelete").Visible = false;
            //            UCGridButtons1.FindControl("btnCreate").Visible = false;
            //            UCGridButtons2.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons2.FindControl("btnDelete").Visible = false;
            //        }
            //        break;
            //    case "PendingRequirement":
            //        pendingrequirements = codeFacede.GetPendingRequirements("CodeId ASC");
            //        if (pendingrequirements.Count > 0)
            //        {
            //        UCGrid1.SetDataSource(pendingrequirements, hideColumn);
            //        }
            //        else
            //        {
            //            //Response.Write("<script>alert('The data table is empty.So please enter some data !!!');</script>");
            //            UCGridButtons1.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons1.FindControl("btnDelete").Visible = false;
            //            UCGridButtons1.FindControl("btnCreate").Visible = false;
            //            UCGridButtons2.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons2.FindControl("btnDelete").Visible = false;
            //        }
            //        break;
            //    case "PendingStatus":
            //        pendingstatuss = codeFacede.GetPendingStatuss("CodeId ASC");
            //        if (pendingstatuss.Count > 0)
            //        {
            //        UCGrid1.SetDataSource(pendingstatuss, hideColumn);
            //        }
            //        else
            //        {
            //            //Response.Write("<script>alert('The data table is empty.So please enter some data !!!');</script>");
            //            UCGridButtons1.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons1.FindControl("btnDelete").Visible = false;
            //            UCGridButtons1.FindControl("btnCreate").Visible = false;
            //            UCGridButtons2.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons2.FindControl("btnDelete").Visible = false;
            //        }
            //        break;
            //    case "PolicyStatus":
            //        policystatuss = codeFacede.GetPolicyStatuss("CodeId ASC");
            //        if (policystatuss.Count > 0)
            //        {
            //        UCGrid1.SetDataSource(policystatuss, hideColumn);
            //        }
            //        else
            //        {
            //            //Response.Write("<script>alert('The data table is empty.So please enter some data !!!');</script>");
            //            UCGridButtons1.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons1.FindControl("btnDelete").Visible = false;
            //            UCGridButtons1.FindControl("btnCreate").Visible = false;
            //            UCGridButtons2.FindControl("btnUpdate").Visible = false;
            //            UCGridButtons2.FindControl("btnDelete").Visible = false;
            //        }
            //        break;
            //    case "Select...":
            //       Response.Redirect("~/UserManagement/CodeType.aspx", false);
            //        //Server.Transfer("~/UserManagement/CodeType.aspx");
            //        break;

            //    default:
            //        break;

            //}

        }
        //public bool GetCountry(Country country) {
        //    if (country.CodeId == int.Parse(Session["/UserManagement/CodeType.aspxview"].ToString()))
        //    return true;
        //else
        //    return false;
        //}




        private void DeleteCodeTypes()
        {

            //DropDownList dldelete = (DropDownList)this.FindControl("TypeDropDownList");
            switch (TypeDropDownList.Text)
            {
                case "Country":
                    try
                    {
                        String codeType = Session["codeId"].ToString();
                        int codeID = int.Parse(codeType);


                        Country country = new Country();
                        CodeFacade objFacade = new CodeFacade();
                        country = objFacade.GetCountry(codeID);
                        successDel = objFacade.DeleteCodeCountry(country);


                        //Country country = new Country();
                        //country = countries.Find(GetCountry);
                        //CodeFacade objFacade = new CodeFacade();
                        //successDel = objFacade.DeleteCodeCountry(country);

                        if (successDel == 1)
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Green;
                            lblUpdateMsg.Text = "Successfully deleted. ";
                            
                            
                        }
                        else
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Red;
                            lblUpdateMsg.Text = "Failed to delete. ";
                           
                        } 
                    }
                    catch (Exception ex)
                    {
                    }
                    break;


                case "Month":
                    try
                    {
                        String codeType = Session["codeId"].ToString();
                        int codeID = int.Parse(codeType);

                        Month codeMonthObject = new Month();
                        CodeFacade objFacade = new CodeFacade();
                        codeMonthObject = objFacade.GetMonth(codeID);
                        successDel = objFacade.DeleteCodeMonth(codeMonthObject);

                        if (successDel == 1)
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Green;
                            lblUpdateMsg.Text = "Successfully deleted.";
                        }
                        else
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Red;
                            lblUpdateMsg.Text = "Failed to delete. ";
                        }
                        
                    }
                    catch (Exception ex)
                    {
                    }
                    break;


                case "ClaimStatus":
                    try
                    {
                        String codeType = Session["codeId"].ToString();
                        int codeID = int.Parse(codeType);

                        ClaimStatus codeClaimStatusObject = new ClaimStatus();
                        CodeFacade objFacade = new CodeFacade();
                        codeClaimStatusObject = objFacade.GetClaimStatus(codeID);
                        successDel = objFacade.DeleteCodeClaimStatus(codeClaimStatusObject);

                        if (successDel == 1)
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Green;
                            lblUpdateMsg.Text = "Successfully deleted. ";
                        }
                        else
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Red;
                            lblUpdateMsg.Text = "Failed to delete. ";
                        }
                        
                    }
                    catch (Exception ex)
                    {
                    }
                    break;


                case "CompaintSubType":
                    try
                    {
                        String codeType = Session["codeId"].ToString();
                        int codeID = int.Parse(codeType);

                        CompaintSubType codeCompaintSubTypeObject = new CompaintSubType();
                        CodeFacade objFacade = new CodeFacade();
                        codeCompaintSubTypeObject = objFacade.GetCompaintSubType(codeID);
                        successDel = objFacade.DeleteCodeCompaintSubType(codeCompaintSubTypeObject);

                        if (successDel == 1)
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Green;
                            lblUpdateMsg.Text = "Successfully deleted. ";
                        }
                        else
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Red;
                            lblUpdateMsg.Text = "Failed to delete. ";
                        }
                        
                    }
                    catch (Exception ex)
                    {
                    }
                    break;

                case "CompetionType":
                    try
                    {
                        String codeType = Session["codeId"].ToString();
                        int codeID = int.Parse(codeType);

                        CompetionType codeCompetionTypeObject = new CompetionType();
                        CodeFacade objFacade = new CodeFacade();
                        codeCompetionTypeObject = objFacade.GetCompetionType(codeID);
                        successDel = objFacade.DeleteCodeCompetionType(codeCompetionTypeObject);

                        if (successDel == 1)
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Green;
                            lblUpdateMsg.Text = "Successfully deleted. ";
                        }
                        else
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Red;
                            lblUpdateMsg.Text = "Failed to delete. ";
                        }
                        
                    }
                    catch (Exception ex)
                    {
                    }
                    break;


                case "ComplaintStatus":
                    try
                    {
                        String codeType = Session["codeId"].ToString();
                        int codeID = int.Parse(codeType);

                        ComplaintStatus codeComplaintStatusObject = new ComplaintStatus();
                        CodeFacade objFacade = new CodeFacade();
                        codeComplaintStatusObject = objFacade.GetComplaintStatus(codeID);
                        successDel = objFacade.DeleteCodeComplaintStatus(codeComplaintStatusObject);

                        if (successDel == 1)
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Green;
                            lblUpdateMsg.Text = "Successfully deleted.";
                        }
                        else
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Red;
                            lblUpdateMsg.Text = "Failed to delete. ";
                        }
                        
                    }
                    catch (Exception ex)
                    {
                    }
                    break;



                case "ComplaintType":
                    try
                    {
                        String codeType = Session["codeId"].ToString();
                        int codeID = int.Parse(codeType);

                        ComplaintType codeComplaintTypeObject = new ComplaintType();
                        CodeFacade objFacade = new CodeFacade();
                        codeComplaintTypeObject = objFacade.GetComplaintType(codeID);
                        successDel = objFacade.DeleteCodeComplaintType(codeComplaintTypeObject);

                        if (successDel == 1)
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Green;
                            lblUpdateMsg.Text = "Successfully deleted. ";
                        }
                        else
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Red;
                            lblUpdateMsg.Text = "Failed to delete. ";
                        }
                        
                    }
                    catch (Exception ex)
                    {
                    }
                    break;


                case "IDType":
                    try
                    {
                        String codeType = Session["codeId"].ToString();
                        int codeID = int.Parse(codeType);

                        IDType codeIDTypeObject = new IDType();
                        CodeFacade objFacade = new CodeFacade();
                        codeIDTypeObject = objFacade.GetIDType(codeID);
                        successDel = objFacade.DeleteCodeIDType(codeIDTypeObject);

                        if (successDel == 1)
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Green;
                            lblUpdateMsg.Text = "Successfully deleted. ";
                        }
                        else
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Red;
                            lblUpdateMsg.Text = "Failed to delete. ";
                        }
                        
                    }
                    catch (Exception ex)
                    {
                    }
                    break;


                case "InformationType":
                    try
                    {
                        String codeType = Session["codeId"].ToString();
                        int codeID = int.Parse(codeType);

                        InformationType codeInformationTypeObject = new InformationType();
                        CodeFacade objFacade = new CodeFacade();
                        codeInformationTypeObject = objFacade.GetInformationType(codeID);
                        successDel = objFacade.DeleteCodeInformationType(codeInformationTypeObject);

                        if (successDel == 1)
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Green;
                            lblUpdateMsg.Text = "Successfully deleted. ";
                        }
                        else
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Red;
                            lblUpdateMsg.Text = "Failed to delete. ";
                        }
                        
                    }
                    catch (Exception ex)
                    {
                    }
                    break;


                case "MaritalStatus":
                    try
                    {
                        String codeType = Session["codeId"].ToString();
                        int codeID = int.Parse(codeType);

                        MaritalStatus codeMaritalStatusObject = new MaritalStatus();
                        CodeFacade objFacade = new CodeFacade();
                        codeMaritalStatusObject = objFacade.GetMaritalStatus(codeID);
                        successDel = objFacade.DeleteCodeMaritalStatus(codeMaritalStatusObject);

                        if (successDel == 1)
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Green;
                            lblUpdateMsg.Text = "Successfully deleted. ";
                        }
                        else
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Red;
                            lblUpdateMsg.Text = "Failed to delete. ";
                        }
                        
                    }
                    catch (Exception ex)
                    {
                    }
                    break;


                case "PolicyType":
                    try
                    {
                        String codeType = Session["codeId"].ToString();
                        int codeID = int.Parse(codeType);

                        PolicyType codePolicyTypeObject = new PolicyType();
                        CodeFacade objFacade = new CodeFacade();
                        codePolicyTypeObject = objFacade.GetPolicyType(codeID);
                        successDel = objFacade.DeleteCodePolicyType(codePolicyTypeObject);

                        if (successDel == 1)
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Green;
                            lblUpdateMsg.Text = "Successfully deleted. ";
                        }
                        else
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Red;
                            lblUpdateMsg.Text = "Failed to delete. ";
                        }
                        
                    }
                    catch (Exception ex)
                    {
                    }
                    break;


                case "PolicyStatus":
                    try
                    {
                        String codeType = Session["codeId"].ToString();
                        int codeID = int.Parse(codeType);

                        PolicyStatus codePolicyStatusObject = new PolicyStatus();
                        CodeFacade objFacade = new CodeFacade();
                        codePolicyStatusObject = objFacade.GetPolicyStatus(codeID);
                        successDel = objFacade.DeleteCodePolicyStatus(codePolicyStatusObject);

                        if (successDel == 1)
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Green;
                            lblUpdateMsg.Text = "Successfully deleted. ";
                        }
                        else
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Red;
                            lblUpdateMsg.Text = "Failed to delete. ";
                        }
                        
                    }
                    catch (Exception ex)
                    {
                    }
                    break;

                case "Salutation":
                    try
                    {
                        String codeType = Session["codeId"].ToString();
                        int codeID = int.Parse(codeType);

                        Salutation codeSalutationObject = new Salutation();
                        CodeFacade objFacade = new CodeFacade();
                        codeSalutationObject = objFacade.GetSalutation(codeID);
                        successDel = objFacade.DeleteCodeSalutation(codeSalutationObject);

                        if (successDel == 1)
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Green;
                            lblUpdateMsg.Text = "Successfully deleted. ";
                        }
                        else
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Red;
                            lblUpdateMsg.Text = "Failed to delete. ";
                        }
                        
                    }
                    catch (Exception ex)
                    {
                    }
                    break;


                case "Measure":
                    try
                    {
                        String codeType = Session["codeId"].ToString();
                        int codeID = int.Parse(codeType);

                        Measure codeMeasureObject = new Measure();
                        CodeFacade objFacade = new CodeFacade();
                        codeMeasureObject = objFacade.GetMeasure(codeID);
                        successDel = objFacade.DeleteCodeMeasure(codeMeasureObject);

                        if (successDel == 1)
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Green;
                            lblUpdateMsg.Text = "Successfully deleted. ";
                        }
                        else
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Red;
                            lblUpdateMsg.Text = "Failed to delete. ";
                        }
                        
                    }
                    catch (Exception ex)
                    {
                    }
                    break;


                case "SOType":
                    try
                    {
                        String codeType = Session["codeId"].ToString();
                        int codeID = int.Parse(codeType);

                        SOType codeSOTypeObject = new SOType();
                        CodeFacade objFacade = new CodeFacade();
                        codeSOTypeObject = objFacade.GetSOType(codeID);
                        successDel = objFacade.DeleteCodeSOType(codeSOTypeObject);

                        if (successDel == 1)
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Green;
                            lblUpdateMsg.Text = "Successfully deleted. ";
                        }
                        else
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Red;
                            lblUpdateMsg.Text = "Failed to delete. ";
                        }
                        
                    }
                    catch (Exception ex)
                    {
                    }
                    break;


                case "PaymentMode":
                    try
                    {
                        String codeType = Session["codeId"].ToString();
                        int codeID = int.Parse(codeType);

                        PaymentMode codePaymentModeObject = new PaymentMode();
                        CodeFacade objFacade = new CodeFacade();
                        codePaymentModeObject = objFacade.GetPaymentMode(codeID);
                        successDel = objFacade.DeleteCodePaymentMode(codePaymentModeObject);

                        if (successDel == 1)
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Green;
                            lblUpdateMsg.Text = "Successfully deleted. ";
                        }
                        else
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Red;
                            lblUpdateMsg.Text = "Failed to delete. ";
                        }
                        
                    }
                    catch (Exception ex)
                    {
                    }
                    break;


                case "PendingRequirement":
                    try
                    {
                        String codeType = Session["codeId"].ToString();
                        int codeID = int.Parse(codeType);

                        PendingRequirement codePendingRequirementObject = new PendingRequirement();
                        CodeFacade objFacade = new CodeFacade();
                        codePendingRequirementObject = objFacade.GetPendingRequirement(codeID);
                        successDel = objFacade.DeleteCodePendingRequirement(codePendingRequirementObject);

                        if (successDel == 1)
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Green;
                            lblUpdateMsg.Text = "Successfully deleted. ";
                        }
                        else
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Red;
                            lblUpdateMsg.Text = "Failed to delete. ";
                        }
                        
                    }
                    catch (Exception ex)
                    {
                    }
                    break;

                case "PendingStatus":
                    try
                    {
                        String codeType = Session["codeId"].ToString();
                        int codeID = int.Parse(codeType);

                        PendingStatus codePendingStatusObject = new PendingStatus();
                        CodeFacade objFacade = new CodeFacade();
                        codePendingStatusObject = objFacade.GetPendingStatus(codeID);
                        successDel = objFacade.DeleteCodePendingStatus(codePendingStatusObject);

                        if (successDel == 1)
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Green;
                            lblUpdateMsg.Text = "Successfully deleted. ";
                        }
                        else
                        {
                            lblUpdateMsg.Font.Bold = true;
                            lblUpdateMsg.ForeColor = System.Drawing.Color.Red;
                            lblUpdateMsg.Text = "Failed to delete. ";
                        }
                        
                    }
                    catch (Exception ex)
                    {
                    }
                    break;

                default:
                    break;
            }


        }

        

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Session["selectValue"] = TypeDropDownList.SelectedValue;
            String type = TypeDropDownList.Text;
            SelectCodeTypeTables(type);
            
        }

        protected void TypeDropDownList_TextChanged(object sender, EventArgs e)
        {

        }

        protected void CreateButton_Click(object sender, EventArgs e)
        {

        
        }

        protected void DeleteButton_Click(object sender, EventArgs e)
        {

          
        }



        #region IDataPage Members


        public void GetId(GridViewRow row)
        {
            Session["codeId"] = row.Cells[2].Text;
        }

        #endregion
    }
}
